import 'package:library_base/entities/generated/json/base/json_field.dart';
import 'package:library_base/entities/generated/json/summary_entity.g.dart';
import 'package:library_base/entities/summary_child_entity.dart';
import 'dart:convert';

@JsonSerializable()
class SummaryEntity {
  late List<SummaryChildEntity> orderDetails;

  late String shipperId;
  late String shipperName;
  late String goodsCode;
  late String goodsName;
  late String goodsUnit;
  late double totalCount;
  late double standardWeight;

  bool get isSelect {
    for (var element in orderDetails) {
      if (!element.isSelect) {
        return false;
      }
    }
    return true;
  }

  set isSelect(bool isSelect) {
    for (var element in orderDetails) {
      element.isSelect = isSelect;
    }
  }

  bool isExpand = false;

  SummaryEntity();

  factory SummaryEntity.fromJson(Map<String, dynamic> json) => $SummaryEntityFromJson(json);

  Map<String, dynamic> toJson() => $SummaryEntityToJson(this);

  @override
  String toString() => json.encode(this);
}
